home *** CD-ROM | disk | FTP | other *** search
- /*
- CDEject - An XFCN to eject a CD
- ©Apple Computer, Inc. 1988
- All Rights Reserved.
-
- 88/11/08 BL°B First Version
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- C -q2 CDEject.c
- link -sn Main=CDEject -sn STDIO=CDEject ∂
- -sn INTENV=CDEject -rt XFCN=42 ∂
- -m CDEject CDEject.c.o "{CLibraries}"CRuntime.o ∂
- "{CLibraries}"StdCLib.o ∂
- -o HyperCommands
-
- This link directive puts the XCMD in the file "HyperCommands".
- Substitute the name of the stack you want it in. To move XCMDs
- between stacks, use ResEdit. They can be in an individual stack,
- the Home stack, the HyperCard application, or the System File.
-
- */
-
- #include <cd.h>
-
- /* prototype definitions for functions */
- OSErr AEject(short, short);
-
- /* **** WARNING: DO NOT USE GLOBAL VARIABLES! **** */
-
-
- /************************************************************************
- *
- * Function: CDEject
- *
- * Purpose: eject a disk
- *
- * Returns: result of driver calls
- * normally 0, but could have parameter error or
- * other error
- *
- * Side Effects:
- *
- * Description: Grab the global which contains both refNums.
- * extract the two and issue and eject and unmount.
- *
- ************************************************************************/
- pascal void
- CDEject(paramPtr)
- XCmdBlockPtr paramPtr;
- {
- Str31 returnString;
- OSErr result;
- short dRefNum;
- short vRefNum;
- long bothRefNums;
- Handle refHandle;
- CntrlParam myPB;
-
-
- /* Must be no parameters */
- if ((paramPtr->paramCount) != 0)
- {
- /* Report error in parameters by returning -1 */
- NumToStr(paramPtr, (long) -1, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- return;
- }
-
- /* Get the global ioRefNum and convert it. */
- refHandle = GetGlobal(paramPtr, GLOBALNAME);
- bothRefNums = atoi(*(refHandle));
- DisposHandle(refHandle);
-
- dRefNum = bothRefNums & 0xFFFF;
- vRefNum = bothRefNums >> 16;
-
- if (vRefNum == 0)
- result = volOffLinErr;
- else
- {
- myPB.ioCompletion = 0;
- myPB.ioNamePtr = nil;
- myPB.ioVRefNum = vRefNum;
- result = PBEject(&myPB);
- if (result == noErr)
- result = PBUnmountVol(&myPB);
- }
-
- /* Convert result to string & return it as error */
- NumToStr(paramPtr, (long) result, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- }
-
-
- /* C routines for HyperCard callbacks */
- #include <XCmdGlue.inc.c>
-